package sm.test;

import java.util.List;

import org.hibernate.Query;
import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.hibernate.cfg.Configuration;

import com.google.gson.Gson;
import com.google.gson.GsonBuilder;

public class DataTest2 {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		Configuration config = new Configuration().configure().addResource(
				"hbm/ocmlwork.hbm.xml");
		SessionFactory sessionFactory = config.buildSessionFactory();
		Session session = sessionFactory.openSession();

		Query query = session.createQuery("from ocmlwork_");
		List<Object> datas = (List<Object>) query.list();

		if (datas.size() > 0) {
			Object data = datas.get(0);
			Gson gson = new GsonBuilder().serializeNulls().setPrettyPrinting()
					.create();
			System.out.println(gson.toJson(data));
		}

		session.close();
	}

}
